import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.InputMismatchException;
import java.util.Scanner;

class Config{
    File file;
    //
    public void OpenConfig(String filename) throws IOException,FileNotFoundException{
        if (filename.endsWith(".ini")){
            throw new IOException("文件不是.ini文件");
        }
        if (filename.equals("config.ini")){
            throw new FileNotFoundException("配置文件名字不对");
        }
        // 打开文件
    }
    public void readConfig(){

    }
}

public class Test {

    public static void main(String[] args) {
        try(Scanner scanner= new Scanner(System.in)){
            int a=scanner.nextInt();
            System.out.println(a);
        }catch(InputMismatchException e){
            System.out.println("InputMismatchException异常...");
            e.printStackTrace();
        }finally{
            System.out.println("finally执行了...");
        }
    }

    public static void main7(String[] args) {
        try{
            int[] array={1,2,3,4,5};
          /*array[7]=100;
           array=null;*/
            System.out.println(array.length);
        }catch(NullPointerException e){
            System.out.println("捕获了 NullPointerException 异常");
            e.printStackTrace();
        }catch(ArrayIndexOutOfBoundsException e) {
            System.out.println("捕获了 ArrayIndexOutOfBoundsException  异常");
            e.printStackTrace();

        }finally{
            //释放资源
            System.out.println("finally被执行了....");
        }

       /* try{
            int[] array={1,2,3,4,5};
            array[7]=100;
        } catch (NullPointerException | ArrayIndexOutOfBoundsException e) {
          System.out.println("捕获了NullPointerException 和 ArrayIndexOutOfBoundsException 异常");
          e.printStackTrace();
        }*/

    }

    public static void OpenConfig(String filename) throws FileNotFoundException{
        if (filename.equals("config.ini")){
            throw new FileNotFoundException("配置文件名字不对");
        }
    }

    public static void main6(String[] args) {
        try{
            OpenConfig("config.ini");
            System.out.println("哈哈哈哈");
        }catch (FileNotFoundException e){
            System.out.println("捕获到了 FileNotFoundException 异常... 开始处理异常...");
            e.printStackTrace();

        }catch (NullPointerException e){

        }
        System.out.println("异常处理完毕，开始执行下一步...");
    }

    /*public static void OpenConfig(String filename) throws FileNotFoundException{
        if (filename.equals("config.ini")){
            throw new FileNotFoundException("配置文件名字不对")
        }
    }

    public static void main(String[] args) {
        OpenConfig("config");
    }*/

    public static void func(int[] array,int index) {
        if (array==null){
            throw new NullPointerException();
            //System.out.println("fdsfsadsasaf");
        }
        System.out.println("hahahahhahahah");
        if (index>array.length){
            throw new ArrayIndexOutOfBoundsException();
        }
    }


   // public static void main(String[] args) throws CloneNotSupportedException,FileNotFoundException{

    public static void main2(String[] args) throws Exception {
      int[] array={1,2,3,4,5} ;
        System.out.println(array[10]);

        System.out.println("after");

        //func(null,1);

        int a=10;
        if(a==10){
            throw new CloneNotSupportedException();
        }

        if (a==9) {
            throw new FileNotFoundException();
        }
    }
}
